<%@page import="com.itsm.v17.entity.Suggestion"%>
<%@page import="java.util.LinkedList"%>
<%@page import="org.jfaster.ProxyTemplate"%>
<%@page import="org.jfaster.Template"%>
<%@page import="java.util.List"%>
<%@ page pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String userId=request.getParameter("userId");
String status=request.getParameter("status");
String startDate=request.getParameter("startDate");
String endDate=request.getParameter("endDate");
String message =(String)request.getAttribute("message");
List list =(List)request.getAttribute("list");
if(list==null){list=new LinkedList();}
if(userId==null){userId="";}
if(status==null){status="";}
if(startDate==null){startDate="";}
if(endDate==null){endDate="";}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>意见反馈管理</title>
<link href="<%=basePath%>js/DatePicker/skin/WdatePicker.css" rel="stylesheet" type="text/css">
<link href="<%=basePath%>css/home.css" type="text/css" rel="stylesheet" />
<script src="<%=basePath%>js/DatePicker/WdatePicker.js" type="text/javascript"></script>
<link href="<%=basePath%>js/DatePicker/skin/WdatePicker.css" rel="stylesheet" type="text/css">
<script src="<%=basePath%>itsm/js/ajax.js"></script>
<script src="<%=basePath%>itsm/js/ajax.form.js"></script>
<script src="<%=basePath%>itsm/js/formValidate.js"></script>
<script src="<%=basePath%>itsm/js/select.js"></script>
<script src="<%=basePath%>itsm/js/reSet.js"></script>

<link type="text/css" rel="stylesheet" href="<%=path%>/itsm/PageNavgation/css/PageNavgation.css">
<link type="text/css" rel="stylesheet" href="<%=path%>/itsm/PageNavgation/css/PageNavgation.gray.css">
<script type="text/javascript" src="<%=path%>/itsm/PageNavgation/js/PageNavgation.js"></script>
<script type="text/javascript" src="<%=path%>/itsm/PageNavgation/js/PageNavgation-simple.js"></script>

<style>
.tableblue00 td{
padding:5px;
}
.已阅{
font-color:blue;
color:blue;
}
.bbzxbg2:hover{
background:#dadada;
}
.columnHead td{
background:#e7eaed;
}
</style>
<script>
function query()
{
	var startDate=document.getElementById("startDate").value;
	var endDate=document.getElementById("endDate").value;
	var userId=document.getElementById("userId").value;
	var status=document.getElementById("status").value;
	location.href="<%=path%>/itsm17/suggestion/list?startDate="+startDate+"&endDate="+endDate+"&status="+status+"&userId="+userId+"&size=<%=request.getAttribute("size")%>";
}
</script>
</head>
<body style="padding:5px;margin:0px;">
	    <table width="100%" cellspacing="1" cellpadding="0" border="0" bgcolor="#D6E6F4" class="tableblue00">
                            <tbody>
                            <tr class="bbzxbg2">
                              <td colspan=3 >
                              	 用户ID： <input type="text" id="userId" value="<%=userId%>"  ondblclick="javascript:this.value='';" />
                              	 &nbsp; &nbsp; &nbsp; &nbsp;
                              	  状态:
                              	  <select id="status" name="status" >
                              	  	<option value="" <%if("".equals(status)){out.print("selected='selected'");} %> >全部</option>
                              	 	<option value="未读" <%if("未读".equals(status)){out.print("selected='selected'");} %>>未读</option>
                              	 	<option value="已阅" <%if("已阅".equals(status)){out.print("selected='selected'");} %>>已阅</option>
                              	 </select>
                              	 &nbsp; &nbsp; &nbsp; &nbsp;
                              	 起点时间： <input type="text" id="startDate" value="<%=startDate%>"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
                              	 &nbsp; &nbsp; &nbsp; &nbsp;
                              	 截止时间： <input type="text" id="endDate" value="<%=endDate%>" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
                              	 &nbsp; &nbsp; &nbsp; &nbsp;
                              	 
                              	 <a class="actionbutton"  href='javascript:;' onclick="query()" class="menudiv" style="margin-right: 10px;">查询</a>
                              	 &nbsp;&nbsp;&nbsp; &nbsp;
                              	 <span ><%=message%></span>
   	
                              </td>
                            </tr></tbody>
          </table>
                     <br/>
                     
<table width="100%" cellspacing="1" cellpadding="0" border="0" bgcolor="#D6E6F4" class="tableblue00 ry_box" id="datalist" >
   <tbody>
   <tr class="columnHead" align="center" >
                <td >序号</td>
                <td align="left">时间</td>
                <td align="left">用户ID</td>
                <td align="left">用户名称</td>
                <td align="left">状态</td>
                <td align="left">意见</td>
                <td align="left">回复</td>
                <td align="left">操作</td>
         </tr>
         
   <%
   try
   {
	   for(int i=0;i<list.size();i++)
  		{
  			Suggestion suggestion=(Suggestion)list.get(i);
  			%>
  				<tr class="bbzxbg2">
  				<td><%=(i+1)%></td>
               <td><%=suggestion.getDateTime()%></td>
               <td align="left"><a href="<%=path%>/itsm17/suggestion/list?userId=<%=suggestion.getUserId()%>&size=<%=request.getAttribute("size")%>"><%=suggestion.getUserId()%></a></td>
               <td align="left"><a href="<%=path%>/itsm17/suggestion/list?userId=<%=suggestion.getUserId()%>&size=<%=request.getAttribute("size")%>"><%=suggestion.getUserName()%></a></td>
               <td align="left" ><font class="<%=suggestion.getStatus()%>"><%=suggestion.getStatus()%></font></td>
               <td align="left"><%=suggestion.getContent()%></td>
               <td align="left"><%=suggestion.getReply()%></td>
               <td align="left">
               	  <a href="javascript:;" onclick="editSuggestion('<%=suggestion.getId()%>','<%=suggestion.getStatus()%>')" >处理</a>
               	  &nbsp;&nbsp;&nbsp;&nbsp;
               	  <%--
               	  <a href="javascript:;" onclick="deleteSuggestion('<%=suggestion.getId()%>','<%=(i+1)%>',this)" >删除</a>
               	   --%>
               </td>
        </tr>
  			<%
  		}
	   if(list.size()==0)
	   {
		   out.println("<tr><td colspan=8>无内容</td></tr>");
	   }
   }catch(Exception exception)
   {
	   exception.printStackTrace();
	   out.println("<tr><td colspan=8>"+exception.toString()+"</td></tr>");
   }
   %>
                     
 </tbody>
</table>
<br/>
<div class="page mt10">
         <div class="pagination" id="pagination" ></div>
</div>  <br/>  
                      
  <table width="100%" cellspacing="1" cellpadding="0" border="0" bgcolor="#D6E6F4" class="tableblue00" id="datafrom" style="display:none;" >
                            <tbody>
                            <tr class="bbzxbg2">
                            <td>状态:</td>
                              <td colspan=3 >
                              	<input type="hidden" name="id" id="id" />  
                              	  <select id="statusData" >
                              	 	<option value="未读">未读</option>
                              	 	<option value="已阅">已阅</option>
                              	 </select>
                              </td>
                            </tr>
                            <tr class="bbzxbg2">
                            <td>回复:</td>
                              <td colspan=3 >
                              <textarea rows=3 cols=50 id="reply" name="reply"  ></textarea>
                              </td>
                            </tr>
                            <tr class="bbzxbg2">
                            <td>&nbsp;</td>
                              <td colspan=3 >
                              	  &nbsp; &nbsp; &nbsp; &nbsp;                             	 
                              	 <a class="actionbutton"  href='javascript:;' onclick="save()" class="menudiv" style="margin-right: 10px;">保存</a>
                              	 &nbsp;&nbsp;
                              	 <span id="message"></span>
                              </td>
                            </tr>
                            </tbody>
          </table>
                     <br/>  
                                
<script>
function editSuggestion(id,status)
{
	//alert("edit "+status);
	show("datafrom");
	get("id").value=id;
	setSelectSelected("statusData",status);
	new ajax({'url':'<%=path%>/itsm17/suggestion/getReply','params':'id='+id,'success':function(data){
		get("reply").value=data;
	}});
}
var isDelete=false,aObj;
function deleteSuggestion(id,index,obj)
{
	aObj=obj;
	if(isDelete){alert("稍等...");return;}
	get("message").innerHTML='';
	if(confirm("确定删除第"+index+"条意见？"))
	{
		var args="id="+id;
		obj.innerHTML='正在删除...';
		isDelete=true;
		new ajax({'url':'<%=path%>/itsm17/suggestion/delete','params':args,'success':function(data)
		{
			get("message").innerHTML='';
			var json=toJson(data);
			if(json.result == true)
			{
				window.location.reload();
			}else
			{
				isDelete=false;
				aObj.innerHTML='删除';
				//get("message").innerHTML=json.message;
				alert("删除发生错误："+json.message);
			}
		}});	
	}
}
function save()
{
	get("message").innerHTML='';
	var id=get("id").value;
	var status=get("statusData").value;
	var reply=get("reply").value;
	var args="id="+id+"&status="+status+"&reply="+reply;
	args=encodeURI(encodeURI(args));
	get("message").innerHTML='正在提交...';
	new ajax({'url':'<%=path%>/itsm17/suggestion/save','params':args,'success':function(data)
	{
		get("message").innerHTML='';
		var json=toJson(data);
		if(json.result == true)
		{
			get("message").innerHTML='保存成功';
			//hidden("datafrom");
			window.location.reload();
		}else
		{
			get("message").innerHTML=json.message;
		}
	}});
}

var start=<%=request.getAttribute("start")%>;
var size=<%=request.getAttribute("size")%>;
var count=<%=request.getAttribute("count")%>;
var currentPage=(start/size)+1;
function pageNavCall(index)
{
	//alert(index);
	var tempStart=(index-1)*size;
	var args="start="+tempStart+"&size="+size;
	var startDate=document.getElementById("startDate").value;
	var endDate=document.getElementById("endDate").value;
	var userId=document.getElementById("userId").value;
	var status=document.getElementById("status").value;
	location.href="<%=path%>/itsm17/suggestion/list?startDate="+startDate+"&endDate="+endDate+"&status="+status+"&userId="+userId+"&"+args;
}
var pageNav=new PageNavgation();
pageNav.setHandle(pageNav);
pageNav.setCall(pageNavCall);
pageNav.setAllCount(count);
pageNav.setPageSize(size);
pageNav.setCurrentPage(currentPage);
pageNav.bind("pagination");
</script>                    
                     
</body>
</html>